package com.example.ymm.modules1.controller.ms;

import com.example.ymm.annotation.RequestLimiter;
import com.example.ymm.model.CommonResult;
import com.example.ymm.modules1.controller.BaseController;
import com.example.ymm.modules1.service.user.DbUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/hl/ms/user/userLogin")
@Api(tags = "ms用户端 ")
@Slf4j
public class MsUserController extends BaseController {

    @Autowired
    private DbUserService dbUserService;

    @ApiOperation(value = "钉钉自动登录")
    @RequestLimiter(QPS = 1D)
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public CommonResult login(@RequestParam("code") String code) {
        try {
            return dbUserService.loginH5(code);
        }catch (Exception e){
            log.error(e.getMessage(),e);
            return CommonResult.error(e.getMessage());
        }

    }
}
